<?php

namespace App\Http\Controllers\Console;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Cblink\Region\Region;

class AreasController extends Controller
{

    /**
     * 创建一个新的控制器实例。
     */
    public function __construct()
    {
        $region = new Region();
        $this->region = $region;
    }

    /**
     * @return mixed
     * 全部省份
     */
    public function allProvinces(){

        $values = $this->region->allProvinces();
        return $values;
    }

    /**
     * @return mixed
     * 全部城市
     */
    public function allCities(){
        $values = $this->region->allCities();
        return $values;
    }

    /**
     * @return mixed
     *  全部区
     */
    public function allAreas(){
        $values =  $this->region->allAreas();
        return $values;
    }

    /**
     * @param Request $request
     * @return Region[]|\Illuminate\Database\Eloquent\Collection
     *  展示全部子区域，可指定某个省或市id
     */
    public function nest(Request $request){
        $values = $this->region->nest($request->id);
        return $values;
    }

    /**
     * @param Request $request
     * @return Region[]|\Illuminate\Database\Eloquent\Collection
     * 根据市或区id展示其所有父结构
     */
    public function nestFromChild(Request $request){
        $values = $this->region->nestFromChild($request->id);
        return $values;
    }
}
